Northwoods.GoWPF 2.2.4 Assembly
GraphLinksModelNodeData<NodeKey> Class
Members 

the Type of a value uniquely identifying a node data in the model
A simple representation of node data for GraphLinksModel<NodeType,NodeKey,PortKey,LinkType> that supports property change notification, copying, and undo via the INotifyPropertyChanged, ICloneable, and IChangeDataValue interfaces.
Syntax
Type Parameters
NodeKey
the Type of a value uniquely identifying a node data in the model
Remarks

This provides a standard implementation of GraphLinksModel<NodeType,NodeKey,PortKey,LinkType> data that represents nodes with support for subgraphs, including properties for specifying the containing subgraph node key and/or the collection of member node keys. You can use this class if you do not already have your own application class holding information about nodes and if you want to inherit from an existing class so that you can just add your own properties. Here's a simple example:

[Serializable] public class MyData : GraphLinksModelNodeData<String> { public MyData() { } public String Color { get { return _Color; } set { if (_Color != value) { String old = _Color; _Color = value; RaisePropertyChanged("Color", old, value); } } } private String _Color = "White"; public String Name { get { return _Name; } set { if (_Name != value) { String old = _Name; _Name = value; RaisePropertyChanged("Name", old, value); } } } private String _Name; public String Address { get { return _Address; } set { if (_Address != value) { String old = _Address; _Address = value; RaisePropertyChanged("Address", old, value); } } } private String _Address; } Then you can bind to these data properties in the DataTemplate for your nodes: <DataTemplate x:Key="NodeTemplate"> <Border BorderBrush="Black" BorderThickness="1" CornerRadius="5" Padding="5" Background="{Binding Path=Data.Color, Converter={StaticResource theColorConverter}}" go:Node.Location="{Binding Path=Data.Location, Mode=TwoWay}"> <StackPanel> <TextBlock Text="{Binding Path=Data.Name}" HorizontalAlignment="Left" /> <TextBlock Text="{Binding Path=Data.Address}" HorizontalAlignment="Left" /> </StackPanel> </Border> </DataTemplate>

Note that property setters need to raise the model's Changed event, so that the model knows about changes in the data and can then update the diagram. You should call RaisePropertyChanged only when the value has actually changed, and you should pass both the previous and the new values, in order to support undo/redo.

For both Silverlight and WPF you should override the Clone method if the fields contain data that should not be shared between copies. For WPF the properties that you define should also be serializable, in order for the data to be copiable, especially to and from the clipboard.

If you add properties to this node data class, and if you are using the GraphLinksModel<NodeType,NodeKey,PortKey,LinkType>.Save<NodeDataType,LinkDataType> and GraphLinksModel<NodeType,NodeKey,PortKey,LinkType>.Load<NodeDataType,LinkDataType> methods, you should override the MakeXElement and LoadFromXElement methods to add new attributes and/or elements as needed,

Normally, each Key should have a unique value within the model. You can maintain that yourself, by setting the Key to unique values before adding the node data to the model's collection of nodes. Or you can ensure this by overriding the GraphLinksModel<NodeType,NodeKey,PortKey,LinkType>.MakeNodeKeyUnique method. The override (or the setting of the same-named delegate in GraphLinksModel<NodeType,NodeKey,PortKey,LinkType>.Delegates) is required if nodes might be copied within the model.

If you want each node to keep a "reference" to the containing ("parent") group, you can use the SubGraphKey property. If you want subgraph data to keep a list of "references" to the contained ("children") nodes, you can use the MemberKeys property. You can use both properties at the same time.

This class is not useful with GraphModel<NodeType,NodeKey> or TreeModel<NodeType,NodeKey>.

Inheritance Hierarchy

System.Object
   Northwoods.GoXam.Model.GraphLinksModelNodeData<NodeKey>

Requirements
See Also

Reference

GraphLinksModelNodeData<NodeKey> Members
Northwoods.GoXam.Model Namespace

 

 


© Northwoods Software 2017. All Rights Reserved.

Send Feedback